Skip to content

Split Codecompanion Tools for fine-grained control and drop slash command#192

Merged
Davidyz merged 13 commits intomainfrom
nvim/split_codecompanion_tools
Jun 18, 2025
Merged

Split Codecompanion Tools for fine-grained control and drop slash command#192
Davidyz merged 13 commits intomainfrom
nvim/split_codecompanion_tools

Conversation

@Davidyz
Copy link
Owner

@Davidyz Davidyz commented Jun 17, 2025

This PR splits the codecompanion tool into separate ls, query and vectorise tools. This'll provide better control and simplify the codebase for future iterations.

The slash command /vectorcode is also being dropped. This is because the tools are more powerful and easier to maintain compared to the slash command. Also, the way it works (using information from the code buffer as query keywords) is suboptimal anyway, at least for an agentic workflow in codecompanion.

EDIT: new extension config:

require('codecompanion').setup({
  extensions = {
    vectorcode = {
      enabled = vim.fn.executable("vectorcode") == 1,
      ---@type VectorCode.CodeCompanion.ExtensionOpts
      opts = {
        tool_group = {
          enabled = true, -- create a `vectorcode_toolbox` tool group that contains all 3 vectorcode tools
          collapse = true,
          extras = {}, -- extra tools to be added to `vectorcode_toolbox`
        },
        tool_opts = {
          -- options for the tools
          ls = { use_lsp = true },
          vectorise = { use_lsp = true },
          query = {
            default_num = { document = 15, chunks = 100 },
            chunk_mode = true,
            use_lsp = true,
          },
        },
      },
    },
  }
})

@Davidyz Davidyz added enhancement New feature or request feature breaking labels Jun 17, 2025
@codecov
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.48%. Comparing base (91d0d8d) to head (4102b17).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #192   +/-   ##
=======================================
  Coverage   99.48%   99.48%           
=======================================
  Files          21       21           
  Lines        1552     1552           
=======================================
  Hits         1544     1544           
  Misses          8        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Davidyz
Copy link
Owner Author

Davidyz commented Jun 17, 2025

image

@Davidyz Davidyz force-pushed the nvim/split_codecompanion_tools branch from 359c7a1 to f584643 Compare June 17, 2025 09:35
@Davidyz
Copy link
Owner Author

Davidyz commented Jun 17, 2025

image
🎉

@Davidyz
Copy link
Owner Author

Davidyz commented Jun 17, 2025

@olimorris just so we're on the same page, it's now recommended to remove individual system_prompt from the individual tools and put the instructions into the description of the schema, correct?

@Davidyz Davidyz changed the title Split Codecompanion Tools for fine-grained control Split Codecompanion Tools for fine-grained control and drop slash command Jun 17, 2025
@olimorris
Copy link
Contributor

it's now recommended to remove individual system_prompt from the individual tools and put the instructions into the description of the schema, correct?

Yep. Ideally the tools should be granular and simple enough that a description will suffice. Of course you have a description field within the parameters as well.

Some examples from GitHub Copilot:

"name": "grep_search",
"description": "Do a text search in the workspace. Use this tool when you know the exact string you're searching for.",

"name": "read_file",
"description": "Read the contents of a file.\n\nYou must specify the line range you're interested in. If the file contents returned are insufficient for your task, you may call this tool again to retrieve more content.",

"name": "list_dir",
"description": "List the contents of a directory. Result will have the name of the child. If the name ends in /, it's a folder, otherwise a file",

@Davidyz Davidyz marked this pull request as ready for review June 18, 2025 05:22
@Davidyz Davidyz merged commit 03f7a30 into main Jun 18, 2025
13 checks passed
@Davidyz Davidyz deleted the nvim/split_codecompanion_tools branch June 18, 2025 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants